package com.rscache.exception;

/**
 * 通用系统错误码：RS开头
 * @ClassName: RscacheErrorCode  
 * @Description: TODO(这里用一句话描述这个类的作用)  
 * @author "Linfeng Han"  
 * @date 2017年1月4日 下午3:40:49
 *
 */
public enum RscacheErrorCode {

	SUCCESS("RS00000", "成功"),

	CACHE_EXCEPTION("RS9999", "缓存异常"),

	REDIS_EXCEPTION("RS0001", "redis异常"),

	NOT_IMPLEMENTS_SERIALIZABLE("RS0002", "缓存对象没有实现可序列化接口")

	;

	private String code = null;

	private String msg = null;

	RscacheErrorCode(String code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public String getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	public static RscacheErrorCode getByCode(String code) {
		if (code == null || code.isEmpty()) {
			return null;
		}

		RscacheErrorCode[] enums = RscacheErrorCode.values();
		for (RscacheErrorCode p : enums) {
			if (p.getCode().equals(code)) {
				return p;
			}
		}

		return null;
	}
}